package com.datawin.taotaocheche.ui.actviity.user.biz;

import java.util.List;

import com.datawin.taotaocheche.base.BaseBiz;
import com.datawin.taotaocheche.base.BaseResp;
import com.datawin.taotaocheche.bean.RechargeSettingInfo;
import com.datawin.taotaocheche.comm.BaseSubscribe2;
import com.datawin.taotaocheche.comm.RetrofitHelp;
import com.datawin.taotaocheche.pay.WxBean;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by admin on 2017/12/2.
 */

public class RechargeBiz extends BaseBiz {

    /**
     * 获取充值优惠
     * @param
     * @param
     * @param callback
     */
    public void getRechargeSetting(String  token,final BaseBiz.Callback<List<RechargeSettingInfo>> callback) {
        com.add(RetrofitHelp.getSecretApi().rechargePage(token)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe2<BaseResp<List<RechargeSettingInfo>>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((List<RechargeSettingInfo>) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((List<RechargeSettingInfo>) obj);
                    }
                })
        );
    }



    /**
     * 支付订单
     * @param rechargeSettingId
     * @param payMethod
     * @param callback
     */
    public void recharge(String userCode, String rechargeSettingId, String payMethod,final BaseBiz.Callback<String> callback) {
        com.add(RetrofitHelp.getSecretApi().rechargeConfirm(userCode,rechargeSettingId, payMethod)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe2<BaseResp<String>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((String) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((String) obj);
                    }
                })
        );
    }

    /**
     * 微信支付订单
     * @param rechargeSettingId
     * @param payMethod
     * @param callback
     */
    public void wexiConfirm(String userCode, String rechargeSettingId, String payMethod,final BaseBiz.Callback<WxBean> callback) {
        com.add(RetrofitHelp.getSecretApi().wexiConfirm(userCode,rechargeSettingId, payMethod)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe2<BaseResp<WxBean>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((WxBean) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((WxBean) obj);
                    }
                })
        );
    }


}
